# encoding=urf-8
import appium.webdriver
from abc import ABCMeta, abstractmethod


class AppBaseAutomation:
    # 指定该类为抽象接口类
    __metaclass__ = ABCMeta

    def __init__(self, plant_name, plant_version, device_name, app_name, app_package, app_activity, driver_hub):
        desired_caps = {}
        desired_caps['platform_name'] = plant_name
        desired_caps['platform_version'] = plant_version
        desired_caps['device_name'] = device_name
        desired_caps['app_name'] = app_name
        desired_caps['app_package'] = app_package
        desired_caps['app_activity'] = app_activity
        drvier_hub = driver_hub

    # 析构方法，断开与appium服务器的连接,退出客户端界面
    def __del__(self):
        self.driver.quit()

    # 启动android系统中的客户端APP
    def app_start(self):
        self.driver = appium.webdriver.Remote(self.driver_hub, self.desired_caps)

    # 定义子类实现的执行实际操作的接口方法
    @abstractmethod
    def app_action(self):
        # 交由子类实现具体的交互细节jiekou
        pass

    def app_slide_left(self):
        pass

    def app_slide_right(self):
        pass

    def app_click(self):
        pass

    def app_slice_up(self):
        pass

    def app_slide_down(self):
        pass
